package com.tport.client.service.impl;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import com.tport.Param;

public class PortClientReadThread extends Thread {
	
	private InputStream is;
	private Socket csocket  = null;
	private Socket ssocket  = null;
	
	public void run() {
		byte[] data = new byte[100000];
		while(true) {
			try {
				int nr = is.read(data);
				if(nr > 0) {
					csocket.getOutputStream().write(data);
					Thread.sleep(100);
					
				}
				if(ssocket.isClosed()) {
					csocket.close();
					break;
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	public InputStream getIs() {
		return is;
	}

	public void setIs(InputStream is) {
		this.is = is;
		try {
			csocket = new Socket("192.168.1.9", 6001);
		}catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public Socket getSsocket() {
		return ssocket;
	}

	public void setSsocket(Socket ssocket) {
		this.ssocket = ssocket;
	}
}
